package com.lanyou.cook.web;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.jxls.area.XlsArea;
import org.jxls.command.EachCommand;
import org.jxls.common.AreaRef;
import org.jxls.common.CellRef;
import org.jxls.common.Context;
import org.jxls.transform.Transformer;
import org.jxls.util.JxlsHelper;
import org.jxls.util.TransformerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ResourceLoader;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.xml.sax.SAXException;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;
import com.lanyou.cook.common.Constants;
import com.lanyou.cook.entity.domain.FieldSystem;
import com.lanyou.cook.entity.domain.InterfaceCount;
import com.lanyou.cook.entity.domain.InterfaceExecutionResult;
import com.lanyou.cook.entity.domain.InterfaceScheduleResult;
import com.lanyou.cook.entity.domain.InterfaceVersionHistory;
import com.lanyou.cook.entity.domain.SlaveServerLog;
import com.lanyou.cook.entity.domain.SystemInterface;
import com.lanyou.cook.entity.domain.UserLog;
import com.lanyou.cook.entity.domain.UserLogOperationCount;
import com.lanyou.cook.importdata.vo.BundleRelationVo;
import com.lanyou.cook.importdata.vo.VisibleVo;
import com.lanyou.cook.repository.FieldSystemRepository;
import com.lanyou.cook.util.gson.GsonUtil;
import com.lanyou.cook.web.param.InterfaceCountParam;
import com.lanyou.cook.web.param.InterfaceExecutionResultParam;
import com.lanyou.cook.web.param.InterfaceScheduleResultParam;
import com.lanyou.cook.web.param.InterfaceVersionHistoryParam;
import com.lanyou.cook.web.param.SlaveServerLogParam;
import com.lanyou.cook.web.param.SystemInterfaceParam;
import com.lanyou.cook.web.param.UserLogParam;
import com.lanyou.esb.entity.DefinedBundle;
import com.lanyou.esb.entity.Ftp;
import com.lanyou.esb.entity.FtpServer;
import com.lanyou.esb.entity.Http;
import com.lanyou.esb.entity.IfAlarmHis;
import com.lanyou.esb.entity.IfParameter;
import com.lanyou.esb.entity.IfReqQuantity;
import com.lanyou.esb.entity.IfSchedule;
import com.lanyou.esb.repository.FtpRepository;
import com.lanyou.esb.repository.HttpRepository;
import com.lanyou.esb.web.FtpLogController;
import com.lanyou.esb.web.IfAlarmHisController;
import com.lanyou.esb.web.SocketLogController;
import com.lanyou.esb.web.param.FtpLogParam;
import com.lanyou.esb.web.param.IfAlarmHisParam;
import com.lanyou.esb.web.param.SocketLogParam;
import com.lanyou.esb.web.serviceManagement.vo.FtpLogVo;
import com.lanyou.esb.web.serviceManagement.vo.SocketLogVo;

/**
 * 导出Excel文件控制层
 * 
 * @author 杨晨睿
 *
 */
@Controller
@RequestMapping(Constants.BASE_URL_API + "/exportDatas")
public class ExportDataToExcelFileController {

	@Autowired
	private ResourceLoader resourceLoader;
	@Autowired
	private UserLogController userLogController;
	@Autowired
	private SystemInterfaceController systemInterfaceController;
	@Autowired
	private InterfaceVersionHistoryController interfaceVersionHistoryController;
	@Autowired
	private InterfaceExecutionResultController interfaceExecutionResultController;
	@Autowired
	private InterfaceScheduleResultController interfaceScheduleResultController;
	@Autowired
	private InterfaceCountController interfaceCountController;
	@Autowired
	private SlaveServerLogController slaveServerLogController;
	
	@Autowired
	private FtpLogController ftpLogController;
	
	@Autowired
	private SocketLogController socketLogController;
	
	@Autowired
	private HttpRepository httpRepository;
	
	@Autowired
	private FtpRepository  ftpRepository;
	
	@Autowired
	private FieldSystemRepository fieldSystemRepository;
	
	@Autowired
	private IfAlarmHisController ifAlarmHisController;

	/**
	 * 领域接口出基本信息导
	 * 
	 * @param param
	 *            类型:String 待导出数据的查询条件
	 * @param request
	 *            类型:HttpServletRequest 客户端请求
	 * @param response
	 *            类型:HttpServletResponse 服务器的响应
	 */
	@ResponseBody
	@RequestMapping(value = "/file/fileInterfaceBasicInfoExport", produces = "application/json")
	public void fileInterfaceBasicInfoExport(String param, HttpServletRequest request, HttpServletResponse response)
			throws IOException, InvalidFormatException, SAXException {
		JsonObject paramJsonObject = GsonUtil.getDefaultJsonParser().parse(param).getAsJsonObject();
		
		SystemInterfaceParam systemInterfaceParam = new Gson().fromJson(paramJsonObject,
				SystemInterfaceParam.class);
		
		Sort sort = new Sort(Direction.DESC, "createTime");
		Pageable pageable = new PageRequest(Constants.DEFAULT_EXPORT_PAGE_COUNT,
				Constants.DEFAULT_EXPORT_DATA_COUNT,sort);

		Page<SystemInterface> pSystemInterfaces = systemInterfaceController.findByExample(systemInterfaceParam,
				pageable);
		
		List<SystemInterface> systemInterfaces = pSystemInterfaces.getContent();
		String fileName = new String( Constants.FIELD_INTERFACE_BASIC_INFORMATION.getBytes("gb2312"), "ISO8859-1" );// 文件名
		InputStream in = resourceLoader.getResource("classpath:jxls/templatestIn/fieldInfo.xls").getInputStream();
		response.setContentType("application/vnd.ms-excel;charset=utf-8");
		response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
		OutputStream os = response.getOutputStream();
		Context context = new Context();
		context.putVar("systemInterfaces", systemInterfaces);
		JxlsHelper.getInstance().processTemplate(in, os, context);
	}

	/**
	 * 领域接口历史信息导出
	 * 
	 * @param param
	 *            类型:String 待导出数据的查询条件
	 * @param request
	 *            类型:HttpServletRequest 客户端请求
	 * @param response
	 *            类型:HttpServletResponse 服务器的响应
	 */
	@ResponseBody
	@RequestMapping(value = "/file/fileInterfaceVersionHistoryExport", produces = "application/json")
	public void fileInterfaceVersionHistoryExport(String param, HttpServletRequest request,
			HttpServletResponse response) throws IOException, InvalidFormatException, SAXException {
		JsonObject paramJsonObject = GsonUtil.getDefaultJsonParser().parse(param).getAsJsonObject();
		InterfaceVersionHistoryParam interfaceVersionHistoryParam = new Gson().fromJson(paramJsonObject,
				InterfaceVersionHistoryParam.class);
		Sort sort = new Sort(Direction.DESC, "createTime");
		Pageable pageable = new PageRequest(Constants.DEFAULT_EXPORT_PAGE_COUNT,
				Constants.DEFAULT_EXPORT_DATA_COUNT,sort);

		Page<InterfaceVersionHistory> pInterfaceVersionHistorys = interfaceVersionHistoryController
				.findByExample(interfaceVersionHistoryParam, pageable);
		
		List<InterfaceVersionHistory> interfaceVersionHistorys = pInterfaceVersionHistorys.getContent();
		String fileName = new String( Constants.FIELD_INTERFACE_HISTORY_INFORMATION.getBytes("gb2312"), "ISO8859-1" );// 文件名
		InputStream in = resourceLoader.getResource("classpath:jxls/templatestIn/fieldHistoryInfo.xls")
				.getInputStream();
		response.setContentType("application/vnd.ms-excel;charset=utf-8");
		response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
		OutputStream os = response.getOutputStream();
		Context context = new Context();
		context.putVar("interfaceVersionHistorys", interfaceVersionHistorys);
		JxlsHelper.getInstance().processTemplate(in, os, context);
	}

	/**
	 * 历史接口执行情况导出
	 * 
	 * @param param
	 *            类型:String 待导出数据的查询条件
	 * @param request
	 *            类型:HttpServletRequest 客户端请求
	 * @param response
	 *            类型:HttpServletResponse 服务器的响应
	 */
	@ResponseBody
	@RequestMapping(value = "/file/historyInterfaceInfoExport", produces = "application/json")
	public void historyInterfaceInfoExport(String param, HttpServletRequest request, HttpServletResponse response)
			throws IOException, InvalidFormatException, SAXException {

		JsonObject paramJsonObject = GsonUtil.getDefaultJsonParser().parse(param).getAsJsonObject();
		InterfaceExecutionResultParam interfaceExecutionResultParam = new Gson().fromJson(paramJsonObject,
				InterfaceExecutionResultParam.class);
		Sort sort = new Sort(Direction.DESC, "createTime");
		Pageable pageable = new PageRequest(Constants.DEFAULT_EXPORT_PAGE_COUNT,
				Constants.DEFAULT_EXPORT_DATA_COUNT,sort);

		Page<InterfaceExecutionResult> interfaceExecutionResult = interfaceExecutionResultController
				.findByExample(interfaceExecutionResultParam, pageable);
		List<InterfaceExecutionResult> interfaceExecutionResults = interfaceExecutionResult.getContent();
		String fileName = new String( Constants.HISTORY_INTERFACE_IMPLEMENTATION.getBytes("gb2312"), "ISO8859-1" );// 文件名
		InputStream in = resourceLoader.getResource("classpath:jxls/templatestIn/historyInterfaceExecutionResult.xls")
				.getInputStream();
		response.setContentType("application/vnd.ms-excel;charset=utf-8");
		response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
		OutputStream os = response.getOutputStream();
		Context context = new Context();
		context.putVar("interfaceExecutionResults", interfaceExecutionResults);
		JxlsHelper.getInstance().processTemplate(in, os, context);
	}

	/**
	 * 失败告警信息上报导出
	 * 
	 * @param param
	 *            类型:String 待导出数据的查询条件
	 * @param request
	 *            类型:HttpServletRequest 客户端请求
	 * @param response
	 *            类型:HttpServletResponse 服务器的响应
	 */
	@ResponseBody
	@RequestMapping(value = "/file/failInterfaceScheduleExport", produces = "application/json")
	public void failInterfaceSchedule(String param, HttpServletRequest request, HttpServletResponse response)
			throws IOException, InvalidFormatException, SAXException {

		JsonObject paramJsonObject = GsonUtil.getDefaultJsonParser().parse(param).getAsJsonObject();
		InterfaceExecutionResultParam interfaceExecutionResultParam = new Gson().fromJson(paramJsonObject,
				InterfaceExecutionResultParam.class);
		Sort sort = new Sort(Direction.DESC, "createTime");
		Pageable pageable = new PageRequest(Constants.DEFAULT_EXPORT_PAGE_COUNT,
				Constants.DEFAULT_EXPORT_DATA_COUNT,sort);

		Page<InterfaceExecutionResult> interfaceExecutionResult = interfaceExecutionResultController
				.faildInterface(interfaceExecutionResultParam, pageable);
		List<InterfaceExecutionResult> interfaceExecutionResults = interfaceExecutionResult.getContent();
		String fileName = new String( Constants.FAILURE_WARNING_REPORT.getBytes("gb2312"), "ISO8859-1" );// 文件名
		InputStream in = resourceLoader.getResource("classpath:jxls/templatestIn/failInterfaceSchedule.xls")
				.getInputStream();
		response.setContentType("application/vnd.ms-excel;charset=utf-8");
		response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
		OutputStream os = response.getOutputStream();
		Context context = new Context();
		context.putVar("interfaceExecutionResults", interfaceExecutionResults);
		JxlsHelper.getInstance().processTemplate(in, os, context);
	}

	/**
	 * 系统用户日志导出
	 * 
	 * @param param
	 *            类型:String 待导出数据的查询条件
	 * @param request
	 *            类型:HttpServletRequest 客户端请求
	 * @param response
	 *            类型:HttpServletResponse 服务器的响应
	 */
	@ResponseBody
	@RequestMapping(value = "/file/userLogExport", produces = "application/json")
	public void userLog(String param, HttpServletRequest request, HttpServletResponse response)
			throws IOException, InvalidFormatException, SAXException {

		JsonObject paramJsonObject = GsonUtil.getDefaultJsonParser().parse(param).getAsJsonObject();
		UserLogParam userLogParam = new Gson().fromJson(paramJsonObject, UserLogParam.class);
		Sort sort = new Sort(Direction.DESC, "createTime");
		Pageable pageable = new PageRequest(Constants.DEFAULT_EXPORT_PAGE_COUNT,
				Constants.DEFAULT_EXPORT_DATA_COUNT,sort);
		Page<UserLog> userLog = userLogController.findByExample(userLogParam, pageable);
		List<UserLog> userLogs = userLog.getContent();
		String fileName = new String( Constants.SYSTEM_USER_LOG.getBytes("gb2312"), "ISO8859-1" );// 文件名
		InputStream in = resourceLoader.getResource("classpath:jxls/templatestIn/userLog.xls").getInputStream();
		response.setContentType("application/vnd.ms-excel;charset=utf-8");
		response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
		OutputStream os = response.getOutputStream();
		Context context = new Context();
		context.putVar("userLogs", userLogs);
		JxlsHelper.getInstance().processTemplate(in, os, context);
	}

	/**
	 * 用户操作统计导出
	 * 
	 * @param param
	 *            类型:String 待导出数据的查询条件
	 * @param request
	 *            类型:HttpServletRequest 客户端请求
	 * @param response
	 *            类型:HttpServletResponse 服务器的响应
	 */
	@ResponseBody
	@RequestMapping(value = "/file/userOperationStatisticsExport", produces = "application/json")
	public void userOperationStatistics(String param, HttpServletRequest request, HttpServletResponse response)
			throws IOException, InvalidFormatException, SAXException, ParseException {
		Gson gson = new Gson();
		JsonObject vo = GsonUtil.getDefaultJsonParser().parse(param).getAsJsonObject();

		String beginOfCreateTime = null;
		String endOfCreateTime = null;
		
		if (vo.get("beginOfCreateTime") != null) {
			beginOfCreateTime = vo.get("beginOfCreateTime").getAsString();
		}
		if (vo.get("endOfCreateTime") != null) {
			endOfCreateTime = vo.get("endOfCreateTime").getAsString();
		}
		
		Sort sort = new Sort(Direction.DESC, "createTime");
		Pageable pageable = new PageRequest(Constants.DEFAULT_EXPORT_PAGE_COUNT,
				Constants.DEFAULT_EXPORT_DATA_COUNT,sort);
		String params = userLogController.countByUserAndOpt(
				vo.get("optType") == null ? null : vo.get("optType").getAsString(),
				vo.get("optPerson") == null ? null : vo.get("optPerson").getAsString(), beginOfCreateTime,
						endOfCreateTime, pageable);
		JsonObject paramJsonObject = GsonUtil.getDefaultJsonParser().parse(params).getAsJsonObject();
		JsonArray paramArray = paramJsonObject.get("content").getAsJsonArray();
		List<UserLogOperationCount> userOperationCounts = gson.fromJson(paramArray,
				new TypeToken<List<UserLogOperationCount>>() {
				}.getType());
		String fileName = new String( Constants.SYSTEM_USER_OPERATION_LOG.getBytes("gb2312"), "ISO8859-1" );// 文件名
		InputStream in = resourceLoader.getResource("classpath:jxls/templatestIn/userOperationCount.xls")
				.getInputStream();
		response.setContentType("application/vnd.ms-excel;charset=utf-8");
		response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
		OutputStream os = response.getOutputStream();
		Context context = new Context();
		context.putVar("userOperationCounts", userOperationCounts);
		JxlsHelper.getInstance().processTemplate(in, os, context);
	}

	/**
	 * 已执行接口汇总导出
	 * 
	 * @param param
	 *            类型:String 待导出数据的查询条件
	 * @param request
	 *            类型:HttpServletRequest 客户端请求
	 * @param response
	 *            类型:HttpServletResponse 服务器的响应
	 */
	@ResponseBody
	@RequestMapping(value = "/file/implementedInterfaceCountExport", produces = "application/json")
	public void implementedInterfaceCount(String param, HttpServletRequest request, HttpServletResponse response)
			throws IOException, InvalidFormatException, SAXException, ParseException {
		
		JsonObject paramJsonObject = GsonUtil.getDefaultJsonParser().parse(param).getAsJsonObject();
		InterfaceCountParam interfaceCountParam = new Gson().fromJson(paramJsonObject,
				InterfaceCountParam.class);
		Sort sort = new Sort(Direction.DESC, "createTime");
		Pageable pageable = new PageRequest(Constants.DEFAULT_EXPORT_PAGE_COUNT,
				Constants.DEFAULT_EXPORT_DATA_COUNT,sort);

		Page<InterfaceCount> interfaceCount = interfaceCountController
				.findByExample(interfaceCountParam, pageable);
		List<InterfaceCount> implementedInterfaceCounts = interfaceCount.getContent();
		String fileName = new String( Constants.IMPLEMENTED_INTERFACE_SUMMARY.getBytes("gb2312"), "ISO8859-1" );// 文件名
		InputStream in = resourceLoader.getResource("classpath:jxls/templatestIn/implementedInterfaceCount.xls")
				.getInputStream();
		response.setContentType("application/vnd.ms-excel;charset=utf-8");
		response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
		OutputStream os = response.getOutputStream();
		Context context = new Context();
		context.putVar("implementedInterfaceCounts", implementedInterfaceCounts);
		JxlsHelper.getInstance().processTemplate(in, os, context);
	}

	/**
	 * 领域系统接口统计导出
	 * 
	 * @param fieldId
	 *            类型:String 领域Id
	 * @param fieldSystemId
	 *            类型:String 领域系统Id
	 * @param request
	 *            类型:HttpServletRequest 客户端请求
	 * @param response
	 *            类型:HttpServletResponse 服务器的响应
	 */
	@ResponseBody
	@RequestMapping(value = "/file/fileSystemInterfaceStatisticsExport", produces = "application/json")
	public void fileSystemInterfaceStatisticsExport(String fieldId, String fieldSystemId, String ifnull,String interfaceType,HttpServletRequest request,
			HttpServletResponse response) throws IOException, InvalidFormatException, SAXException {
		if(StringUtils.equals(ifnull, "全部")){
			ifnull="";
		};
		Pageable pageable = new PageRequest(Constants.DEFAULT_EXPORT_PAGE_COUNT,
				Constants.DEFAULT_EXPORT_DATA_COUNT);

		Page<com.lanyou.cook.web.vo.FieldSystemInterfaceCount> fieldSystemInterfaceCount = systemInterfaceController.countByFieldAndFieldSystem(fieldId, fieldSystemId, pageable, ifnull, interfaceType);
				
		List<com.lanyou.cook.web.vo.FieldSystemInterfaceCount> fieldSystemInterfaceCounts = fieldSystemInterfaceCount.getContent();
		String fileName = new String( Constants.FIELD_SYSTEM_INTERFACE_STATISTICS.getBytes("gb2312"), "ISO8859-1" );// 文件名
		InputStream in = resourceLoader.getResource("classpath:jxls/templatestIn/fieldSystemInterfaceCount.xls")
				.getInputStream();
		response.setContentType("application/vnd.ms-excel;charset=utf-8");
		response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
		OutputStream os = response.getOutputStream();
		Context context = new Context();
		context.putVar("fieldSystemInterfaceCounts", fieldSystemInterfaceCounts);
		JxlsHelper.getInstance().processTemplate(in, os, context);
	}

	/**
	 * 接口版本历史导出
	 * 
	 * @param param
	 *            类型:String 待导出数据的查询条件
	 * @param request
	 *            类型:HttpServletRequest 客户端请求
	 * @param response
	 *            类型:HttpServletResponse 服务器的响应
	 */
	@ResponseBody
	@RequestMapping(value = "/file/InterfaceVersionHistoryExport", produces = "application/json")
	public void InterfaceVersionHistoryExport(String param, HttpServletRequest request, HttpServletResponse response)
			throws IOException, InvalidFormatException, SAXException {

		JsonObject paramJsonObject = GsonUtil.getDefaultJsonParser().parse(param).getAsJsonObject();
		InterfaceVersionHistoryParam interfaceVersionHistoryParam = new Gson().fromJson(paramJsonObject,
				InterfaceVersionHistoryParam.class);
		Sort sort = new Sort(Direction.DESC, "createTime");
		Pageable pageable = new PageRequest(Constants.DEFAULT_EXPORT_PAGE_COUNT,
				Constants.DEFAULT_EXPORT_DATA_COUNT,sort);

		Page<InterfaceVersionHistory> pInterfaceVersionHistorys = interfaceVersionHistoryController
				.findByExample(interfaceVersionHistoryParam, pageable);
		List<InterfaceVersionHistory> interfaceVersionHistorys = pInterfaceVersionHistorys.getContent();
		String fileName = new String( Constants.INTERFACE_VERSION_HISTORY.getBytes("gb2312"), "ISO8859-1" );// 文件名
		InputStream in = resourceLoader.getResource("classpath:jxls/templatestIn/interfaceVersionHistory.xls")
				.getInputStream();
		response.setContentType("application/vnd.ms-excel;charset=utf-8");
		response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
		OutputStream os = response.getOutputStream();
		Context context = new Context();
		context.putVar("interfaceVersionHistorys", interfaceVersionHistorys);
		JxlsHelper.getInstance().processTemplate(in, os, context);
	}

	/**
	 * 接口调度历史导出
	 * 
	 * @param param
	 *            类型:String 待导出数据的查询条件
	 * @param request
	 *            类型:HttpServletRequest 客户端请求
	 * @param response
	 *            类型:HttpServletResponse 服务器的响应
	 */
	@ResponseBody
	@RequestMapping(value = "/file/InterfaceShedulingHistoryExport", produces = "application/json")
	public void InterfaceShedulingHistoryExport(String param, HttpServletRequest request, HttpServletResponse response)
			throws IOException, InvalidFormatException, SAXException {

		JsonObject paramJsonObject = GsonUtil.getDefaultJsonParser().parse(param).getAsJsonObject();
		InterfaceScheduleResultParam interfaceScheduleResultParam = new Gson().fromJson(paramJsonObject,
				InterfaceScheduleResultParam.class);
		Sort sort = new Sort(Direction.DESC, "createTime");
		Pageable pageable = new PageRequest(Constants.DEFAULT_EXPORT_PAGE_COUNT,
				Constants.DEFAULT_EXPORT_DATA_COUNT,sort);

		Page<InterfaceScheduleResult> pInterfaceScheduleResults = interfaceScheduleResultController
				.findByExample(interfaceScheduleResultParam, pageable);
		List<InterfaceScheduleResult> interfaceScheduleResults = pInterfaceScheduleResults.getContent();
		String fileName = new String( Constants.INTERFACE_SCHEDULING_HISTORY.getBytes("gb2312"), "ISO8859-1" );// 文件名
		InputStream in = resourceLoader.getResource("classpath:jxls/templatestIn/interfaceShedulingHistory.xls")
				.getInputStream();
		response.setContentType("application/vnd.ms-excel;charset=utf-8");
		response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
		OutputStream os = response.getOutputStream();
		Context context = new Context();
		context.putVar("interfaceScheduleResults", interfaceScheduleResults);
		JxlsHelper.getInstance().processTemplate(in, os, context);
	}
	
	/**
	 * 节点运行日志导出
	 * @param param
	 * @param request
	 * @param response
	 * @throws IOException
	 * @throws InvalidFormatException
	 * @throws SAXException
	 */
	
	@ResponseBody
	@RequestMapping(value = "/file/KettleServerLogExport", produces = "application/json")
	public void KettleServerLogExport(String param, HttpServletRequest request, HttpServletResponse response)
			throws IOException, InvalidFormatException, SAXException {

		JsonObject paramJsonObject = GsonUtil.getDefaultJsonParser().parse(param).getAsJsonObject();
		SlaveServerLogParam slaveServerLogParam = new Gson().fromJson(paramJsonObject,
				SlaveServerLogParam.class);
		Sort sort = new Sort(Direction.DESC, "createTime");
		Pageable pageable = new PageRequest(Constants.DEFAULT_EXPORT_PAGE_COUNT,
				Constants.DEFAULT_EXPORT_DATA_COUNT,sort);

		Page<SlaveServerLog> pSlaveServerLogResults = slaveServerLogController
				.findByExample(slaveServerLogParam, pageable);
		List<SlaveServerLog> slaveServerLogResults = pSlaveServerLogResults.getContent();
		String fileName = new String( Constants.KETTLE_SERVER_LOG.getBytes("gb2312"), "ISO8859-1" );// 文件名
		InputStream in = resourceLoader.getResource("classpath:jxls/templatestIn/kettleServerLog.xls")
				.getInputStream();
		response.setContentType("application/vnd.ms-excel;charset=utf-8");
		response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
		OutputStream os = response.getOutputStream();
		Context context = new Context();
		context.putVar("slaveServerLogResults", slaveServerLogResults);
		JxlsHelper.getInstance().processTemplate(in, os, context);
	}

	
	/**
	 * 节点运行日志导出
	 * @param param
	 * @param request
	 * @param response
	 * @throws IOException
	 * @throws InvalidFormatException
	 * @throws SAXException
	 */
	
	@ResponseBody
	@RequestMapping(value = "/file/ftpLogExport", produces = "application/json")
	public void ftpLogExport(String param, HttpServletRequest request, HttpServletResponse response)
			throws IOException, InvalidFormatException, SAXException {

		JsonObject paramJsonObject = GsonUtil.getDefaultJsonParser().parse(param).getAsJsonObject();
		FtpLogParam ftpLogParam = new Gson().fromJson(paramJsonObject,
				FtpLogParam.class);
		Sort sort = new Sort(Direction.DESC, "createTime");
		Pageable pageable = new PageRequest(Constants.DEFAULT_EXPORT_PAGE_COUNT,
				Constants.DEFAULT_EXPORT_DATA_COUNT,sort);

		Page<FtpLogVo> pFtpLogResults = ftpLogController
				.findByExample(ftpLogParam, pageable);
		List<FtpLogVo> ftpLogResults = pFtpLogResults.getContent();
		String fileName = new String( Constants.FTP_LOG_NAME.getBytes("gb2312"), "ISO8859-1" );// 文件名
		InputStream in = resourceLoader.getResource("classpath:jxls/templatestIn/FtpLogSearch.xls")
				.getInputStream();
		response.setContentType("application/vnd.ms-excel;charset=utf-8");
		response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
		OutputStream os = response.getOutputStream();
		Context context = new Context();
		context.putVar("ftpLogs", ftpLogResults);
		JxlsHelper.getInstance().processTemplate(in, os, context);
	}
	
	
	/**
	 * 节点运行日志导出
	 * @param param
	 * @param request
	 * @param response
	 * @throws IOException
	 * @throws InvalidFormatException
	 * @throws SAXException
	 */
	
	@ResponseBody
	@RequestMapping(value = "/file/socketLogExport", produces = "application/json")
	public void socketLogExport(String param, HttpServletRequest request, HttpServletResponse response)
			throws IOException, InvalidFormatException, SAXException {

		JsonObject paramJsonObject = GsonUtil.getDefaultJsonParser().parse(param).getAsJsonObject();
		SocketLogParam socketLogParam = new Gson().fromJson(paramJsonObject,
				SocketLogParam.class);
		Sort sort = new Sort(Direction.DESC, "createTime");
		Pageable pageable = new PageRequest(Constants.DEFAULT_EXPORT_PAGE_COUNT,
				Constants.DEFAULT_EXPORT_DATA_COUNT,sort);
		
		Page<SocketLogVo> pSocketLogResults = socketLogController
				.findByExample(socketLogParam, pageable);
		
		List<SocketLogVo> socketLogResults = pSocketLogResults.getContent();
		String fileName = new String( Constants.SOCKET_LOG_NAME.getBytes("gb2312"), "ISO8859-1" );// 文件名
		InputStream in = resourceLoader.getResource("classpath:jxls/templatestIn/SocketLogSearch.xls")
				.getInputStream();
		response.setContentType("application/vnd.ms-excel;charset=utf-8");
		response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
		OutputStream os = response.getOutputStream();
		Context context = new Context();
		context.putVar("socketLogs", socketLogResults);
		JxlsHelper.getInstance().processTemplate(in, os, context);
	}
	
	/**
	 * 服务明细报表导出
	 * @param param
	 * @param request
	 * @param response
	 * @throws IOException
	 * @throws InvalidFormatException
	 * @throws SAXException
	 */
	
	@ResponseBody
	@RequestMapping(value = "/file/serviceInfoExport", produces = "application/json")
	public void ServiceInfoExport(String param, HttpServletRequest request, HttpServletResponse response)
			throws IOException, InvalidFormatException, SAXException {

		JsonObject paramJsonObject = GsonUtil.getDefaultJsonParser().parse(param).getAsJsonObject();
		
		IfAlarmHisParam ifAlarmHisParam = new Gson().fromJson(paramJsonObject,
				IfAlarmHisParam.class);
		
		Pageable pageable = new PageRequest(Constants.DEFAULT_EXPORT_PAGE_COUNT,
				Constants.DEFAULT_EXPORT_DATA_COUNT);

		Page<IfAlarmHis> ifAlarmHis = ifAlarmHisController.ifAlaramHis(ifAlarmHisParam, pageable);
				
		List<IfAlarmHis> ifAlarmHisResults = ifAlarmHis.getContent();
		String fileName = new String( Constants.IF_ALARM_HIS.getBytes("gb2312"), "ISO8859-1" );// 文件名
		InputStream in = resourceLoader.getResource("classpath:jxls/templatestIn/IfAlarmHis.xls")
				.getInputStream();
		response.setContentType("application/vnd.ms-excel;charset=utf-8");
		response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
		OutputStream os = response.getOutputStream();
		Context context = new Context();
		context.putVar("ifAlarmHisResults", ifAlarmHisResults);
		JxlsHelper.getInstance().processTemplate(in, os, context);
	}
	
	
	
	/**
	 * http接口导出
	 * @param param
	 * @param request
	 * @param response
	 * @throws IOException
	 * @throws InvalidFormatException
	 * @throws SAXException
	 */
	
	@ResponseBody
	@RequestMapping(value = "/file/httpInterfaceExport", produces = "application/json")
	public void httpInterfaceExport(String param, HttpServletRequest request, HttpServletResponse response)
			throws IOException, InvalidFormatException, SAXException {

		Collection<String> httpInterfaceIds = new ArrayList<>();
		if(param.contains(",")){
			String[] ids = param.split(",");
			for (String id : ids) {
				httpInterfaceIds.add(id);
			}
		}else{
			httpInterfaceIds.add(param);
		}
		
		List<Http> httpList = httpRepository.findAll(httpInterfaceIds);
		List<IfParameter> paramList = new ArrayList<>();
		List<IfReqQuantity> reqQuantityList = new ArrayList<>();
		List<VisibleVo> visibleVoList = new ArrayList<>();
		List<BundleRelationVo> bundleRelationVoList = new ArrayList<>();
		for (Http http : httpList) {
			Set<IfParameter> paramSet = http.getInterfaceParameter();
			for (IfParameter ifParameter : paramSet) {
				paramList.add(ifParameter);
			}
			
			Set<IfReqQuantity> reqQuantitySet = http.getInterfaceRequestQuantity();
			for (IfReqQuantity ifReqQuantity : reqQuantitySet) {
				reqQuantityList.add(ifReqQuantity);
			}
			
			Set<FieldSystem> visibleVoSet = http.getVisibleFieldSystems();
			for (FieldSystem fieldSystem : visibleVoSet) {
				VisibleVo visibleVo = new VisibleVo();
				FieldSystem fieldSystemV = fieldSystemRepository.findOne(FieldSystem.idSpecification(fieldSystem.getId()));
				visibleVo.setIfId(http.getId());
				visibleVo.setIfVisibleSystemId(fieldSystem.getId());
				visibleVo.setSystemCode(fieldSystemV.getCode());
				visibleVo.setIsEnable(http.getIsEnable());
				visibleVo.setCreator(http.getCreator());
				visibleVo.setCreateTime(http.getCreateTimeForExport());
				visibleVo.setModifier(http.getModifier());
				visibleVo.setModifyTime(http.getModifyTimeForExport());
				visibleVoList.add(visibleVo);
			}
			
			Set<DefinedBundle> bundleRelationSet = http.getDefinedbundles();
			for (DefinedBundle definedBundle : bundleRelationSet) {
				BundleRelationVo bundleRelationVo = new BundleRelationVo();
				bundleRelationVo.setIfId(http.getId());
				bundleRelationVo.setBundleId(definedBundle.getId());
				bundleRelationVo.setIsEnable(http.getIsEnable());
				bundleRelationVo.setCreator(http.getCreator());
				bundleRelationVo.setCreateTime(http.getCreateTimeForExport());
				bundleRelationVo.setModifier(http.getModifier());
				bundleRelationVo.setModifyTime(http.getModifyTimeForExport());
				bundleRelationVoList.add(bundleRelationVo);
				
			}
		}
		String fileName = new String( Constants.HTTP_INTERFACE_INFO.getBytes("gb2312"), "ISO8859-1" );// 文件名
        try(InputStream is = resourceLoader.getResource("classpath:jxls/templatestIn/httpInfo.xls")
				.getInputStream()) {
        	response.setContentType("application/vnd.ms-excel;charset=utf-8");
    		response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
            try (OutputStream os = response.getOutputStream()) {
                Transformer transformer = TransformerFactory.createTransformer(is, os);
                
                //接口信息
                XlsArea httpXlsArea = new XlsArea("Template!A3:AH4", transformer);
                XlsArea httpArea = new XlsArea("Template!A4:AH4", transformer);
                EachCommand httpEachCommand = new EachCommand("httpInfo", "httpList", httpArea);
                httpXlsArea.addCommand(new AreaRef("Template!A4:AH4"), httpEachCommand);
                Context httpComtext = new Context();
                httpComtext.putVar("httpList", httpList);
                httpXlsArea.applyAt(new CellRef("http!A1"), httpComtext);
                httpXlsArea.processFormulas();
                
                //接口参数信息
                XlsArea paramXlsArea = new XlsArea("Template!A7:N8", transformer);
                XlsArea paramArea = new XlsArea("Template!A8:N8", transformer);
                EachCommand paramEachCommand = new EachCommand("paramInfo", "paramList", paramArea);
                paramXlsArea.addCommand(new AreaRef("Template!A8:N8"), paramEachCommand);
                Context paramComtext = new Context();
                paramComtext.putVar("paramList", paramList);
                paramXlsArea.applyAt(new CellRef("param!A1"), paramComtext);
                paramXlsArea.processFormulas();
                
                
                //接口请求量信息
                XlsArea reqQuantityXlsArea = new XlsArea("Template!A11:J12", transformer);
                XlsArea reqQuantityArea = new XlsArea("Template!A12:J12", transformer);
                EachCommand reqQuantityEachCommand = new EachCommand("reqQuantity", "reqQuantityList", reqQuantityArea);
                reqQuantityXlsArea.addCommand(new AreaRef("Template!A12:J12"), reqQuantityEachCommand);
                Context reqQuantityComtext = new Context();
                reqQuantityComtext.putVar("reqQuantityList", reqQuantityList);
                reqQuantityXlsArea.applyAt(new CellRef("reqQuantity!A1"), reqQuantityComtext);
                reqQuantityXlsArea.processFormulas();
                
                
                //接口可见范围信息
                XlsArea visibleVoXlsArea = new XlsArea("Template!A15:H16", transformer);
                XlsArea visibleVoArea = new XlsArea("Template!A16:H16", transformer);
                EachCommand visibleVoEachCommand = new EachCommand("visibleVo", "visibleVoList", visibleVoArea);
                visibleVoXlsArea.addCommand(new AreaRef("Template!A16:H16"), visibleVoEachCommand);
                Context visibleVoComtext = new Context();
                visibleVoComtext.putVar("visibleVoList", visibleVoList);
                visibleVoXlsArea.applyAt(new CellRef("visibleRelation!A1"), visibleVoComtext);
                visibleVoXlsArea.processFormulas();
                
                
                //接口可见范围信息
                XlsArea bundleRelationVoXlsArea = new XlsArea("Template!A19:G20", transformer);
                XlsArea bundleRelationVoArea = new XlsArea("Template!A20:G20", transformer);
                EachCommand bundleRelationVoEachCommand = new EachCommand("bundleRelationVo", "bundleRelationVoList", bundleRelationVoArea);
                bundleRelationVoXlsArea.addCommand(new AreaRef("Template!A20:G20"), bundleRelationVoEachCommand);
                Context bundleRelationVoComtext = new Context();
                bundleRelationVoComtext.putVar("bundleRelationVoList", bundleRelationVoList);
                bundleRelationVoXlsArea.applyAt(new CellRef("bundleRelation!A1"), bundleRelationVoComtext);
                bundleRelationVoXlsArea.processFormulas();
                
                transformer.write();
            }
        }
	}
	
	
	
	/**
	 * ftp接口导出
	 * @param param
	 * @param request
	 * @param response
	 * @throws IOException
	 * @throws InvalidFormatException
	 * @throws SAXException
	 */
	
	@ResponseBody
	@RequestMapping(value = "/file/ftpInterfaceExport", produces = "application/json")
	public void ftpInterfaceExport(String param, HttpServletRequest request, HttpServletResponse response)
			throws IOException, InvalidFormatException, SAXException {

		Collection<String> ftpInterfaceIds = new ArrayList<>();
		if(param.contains(",")){
			String[] ids = param.split(",");
			for (String id : ids) {
				ftpInterfaceIds.add(id);
			}
		}else{
			ftpInterfaceIds.add(param);
		}
		
		List<Ftp> ftpList = ftpRepository.findAll(ftpInterfaceIds);
		List<FtpServer> ftpServerList = new ArrayList<>();
		List<IfSchedule> ifScheduleList = new ArrayList<>();
		List<VisibleVo> visibleVoList = new ArrayList<>();
		List<BundleRelationVo> bundleRelationVoList = new ArrayList<>();
		for (Ftp ftp : ftpList) {
			Set<FtpServer> ftpServerSet = ftp.getFtpServers();
			for (FtpServer ftpServer : ftpServerSet) {
				ftpServerList.add(ftpServer);
			}
			
			Set<IfSchedule> ifScheduleSet = ftp.getIfSchedules();
			for (IfSchedule ifSchedule : ifScheduleSet) {
				ifScheduleList.add(ifSchedule);
			}
			
			Set<FieldSystem> visibleVoSet = ftp.getVisibleFieldSystems();
			for (FieldSystem fieldSystem : visibleVoSet) {
				VisibleVo visibleVo = new VisibleVo();
				FieldSystem fieldSystemV = fieldSystemRepository.findOne(FieldSystem.idSpecification(fieldSystem.getId()));
				visibleVo.setIfId(ftp.getId());
				visibleVo.setIfVisibleSystemId(fieldSystem.getId());
				visibleVo.setSystemCode(fieldSystemV.getCode());
				visibleVo.setIsEnable(ftp.getIsEnable());
				visibleVo.setCreator(ftp.getCreator());
				visibleVo.setCreateTime(ftp.getCreateTimeForExport());
				visibleVo.setModifier(ftp.getModifier());
				visibleVo.setModifyTime(ftp.getModifyTimeForExport());
				visibleVoList.add(visibleVo);
			}
			
			Set<DefinedBundle> bundleRelationSet = ftp.getDefinedbundles();
			for (DefinedBundle definedBundle : bundleRelationSet) {
				BundleRelationVo bundleRelationVo = new BundleRelationVo();
				bundleRelationVo.setIfId(ftp.getId());
				bundleRelationVo.setBundleId(definedBundle.getId());
				bundleRelationVo.setIsEnable(ftp.getIsEnable());
				bundleRelationVo.setCreator(ftp.getCreator());
				bundleRelationVo.setCreateTime(ftp.getCreateTimeForExport());
				bundleRelationVo.setModifier(ftp.getModifier());
				bundleRelationVo.setModifyTime(ftp.getModifyTimeForExport());
				bundleRelationVoList.add(bundleRelationVo);
				
			}
		}
		String fileName = new String( Constants.FTP_INTERFACE_INFO.getBytes("gb2312"), "ISO8859-1" );// 文件名
        try(InputStream is = resourceLoader.getResource("classpath:jxls/templatestIn/ftpInfo.xls")
				.getInputStream()) {
        	response.setContentType("application/vnd.ms-excel;charset=utf-8");
    		response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
            try (OutputStream os = response.getOutputStream()) {
                Transformer transformer = TransformerFactory.createTransformer(is, os);
                
                //ftp接口信息
                XlsArea ftpXlsArea = new XlsArea("Template!A3:V4", transformer);
                XlsArea ftpArea = new XlsArea("Template!A4:V4", transformer);
                EachCommand ftpEachCommand = new EachCommand("ftpInfo", "ftpList", ftpArea);
                ftpXlsArea.addCommand(new AreaRef("Template!A4:V4"), ftpEachCommand);
                Context ftpComtext = new Context();
                ftpComtext.putVar("ftpList", ftpList);
                ftpXlsArea.applyAt(new CellRef("ftp!A1"), ftpComtext);
                ftpXlsArea.processFormulas();
                
                //ftp接口服务器信息
                XlsArea ftpServerXlsArea = new XlsArea("Template!A7:T8", transformer);
                XlsArea ftpServerArea = new XlsArea("Template!A8:T8", transformer);
                EachCommand ftpServerEachCommand = new EachCommand("ftpServerInfo", "ftpServerList", ftpServerArea);
                ftpServerXlsArea.addCommand(new AreaRef("Template!A8:T8"), ftpServerEachCommand);
                Context ftpServerComtext = new Context();
                ftpServerComtext.putVar("ftpServerList", ftpServerList);
                ftpServerXlsArea.applyAt(new CellRef("ftpServer!A1"), ftpServerComtext);
                ftpServerXlsArea.processFormulas();
                
                
                //ftp接口调度信息
                XlsArea ifScheduleXlsArea = new XlsArea("Template!A11:N12", transformer);
                XlsArea ifScheduleArea = new XlsArea("Template!A12:N12", transformer);
                EachCommand ifScheduleEachCommand = new EachCommand("ftpScheduleInfo", "ifScheduleList", ifScheduleArea);
                ifScheduleXlsArea.addCommand(new AreaRef("Template!A12:N12"), ifScheduleEachCommand);
                Context ifScheduleComtext = new Context();
                ifScheduleComtext.putVar("ifScheduleList", ifScheduleList);
                ifScheduleXlsArea.applyAt(new CellRef("ftpSchedule!A1"), ifScheduleComtext);
                ifScheduleXlsArea.processFormulas();
                
                
                //接口可见范围信息
                XlsArea visibleVoXlsArea = new XlsArea("Template!A15:H16", transformer);
                XlsArea visibleVoArea = new XlsArea("Template!A16:H16", transformer);
                EachCommand visibleVoEachCommand = new EachCommand("visibleVo", "visibleVoList", visibleVoArea);
                visibleVoXlsArea.addCommand(new AreaRef("Template!A16:H16"), visibleVoEachCommand);
                Context visibleVoComtext = new Context();
                visibleVoComtext.putVar("visibleVoList", visibleVoList);
                visibleVoXlsArea.applyAt(new CellRef("visibleRelation!A1"), visibleVoComtext);
                visibleVoXlsArea.processFormulas();
                
                
                //接口可见范围信息
                XlsArea bundleRelationVoXlsArea = new XlsArea("Template!A19:G20", transformer);
                XlsArea bundleRelationVoArea = new XlsArea("Template!A20:G20", transformer);
                EachCommand bundleRelationVoEachCommand = new EachCommand("bundleRelationVo", "bundleRelationVoList", bundleRelationVoArea);
                bundleRelationVoXlsArea.addCommand(new AreaRef("Template!A20:G20"), bundleRelationVoEachCommand);
                Context bundleRelationVoComtext = new Context();
                bundleRelationVoComtext.putVar("bundleRelationVoList", bundleRelationVoList);
                bundleRelationVoXlsArea.applyAt(new CellRef("bundleRelation!A1"), bundleRelationVoComtext);
                bundleRelationVoXlsArea.processFormulas();
                
                transformer.write();
            }
        }
	}
	
	
	/**
	 * socket接口导出
	 * @param param
	 * @param request
	 * @param response
	 * @throws IOException
	 * @throws InvalidFormatException
	 * @throws SAXException
	 */
	
//	@ResponseBody
//	@RequestMapping(value = "/file/socketInterfaceExport", produces = "application/json")
//	public void socketInterfaceExport(String param, HttpServletRequest request, HttpServletResponse response)
//			throws IOException, InvalidFormatException, SAXException {
//
//		Collection<String> socketInterfaceIds = new ArrayList<>();
//		if(param.contains(",")){
//			String[] ids = param.split(",");
//			for (String id : ids) {
//				socketInterfaceIds.add(id);
//			}
//		}else{
//			socketInterfaceIds.add(param);
//		}
//		
//		List<Socket> socketList = socketRepository.findAll(socketInterfaceIds);
//		List<SocketServer> socketServerList = new ArrayList<>();
//		List<IfSchedule> ifScheduleList = new ArrayList<>();
//		List<VisibleVo> visibleVoList = new ArrayList<>();
//		for (Socket socket : socketList) {
//			Set<SocketServer> socketServerSet = socket.getSocketServers();
//			for (SocketServer socketServer : socketServerSet) {
//				socketServerList.add(socketServer);
//			}
//			
//			Set<IfSchedule> ifScheduleSet = socket.getIfSchedules();
//			for (IfSchedule ifSchedule : ifScheduleSet) {
//				ifScheduleList.add(ifSchedule);
//			}
//			
//			Set<FieldSystem> visibleVoSet = socket.getVisibleFieldSystems();
//			for (FieldSystem fieldSystem : visibleVoSet) {
//				VisibleVo visibleVo = new VisibleVo();
//				FieldSystem fieldSystemV = fieldSystemRepository.findOne(FieldSystem.idSpecification(fieldSystem.getId()));
//				visibleVo.setIfId(socket.getId());
//				visibleVo.setIfVisibleSystemId(fieldSystem.getId());
//				visibleVo.setSystemCode(fieldSystemV.getCode());
//				visibleVo.setIsEnable(socket.getIsEnable());
//				visibleVo.setCreator(socket.getCreator());
//				visibleVo.setCreateTime(socket.getCreateTimeForExport());
//				visibleVo.setModifier(socket.getModifier());
//				visibleVo.setModifyTime(socket.getModifyTimeForExport());
//				visibleVoList.add(visibleVo);
//			}
//			
//		}
//		String fileName = new String( Constants.SOCKET_INTERFACE_INFO.getBytes("gb2312"), "ISO8859-1" );// 文件名
//        try(InputStream is = resourceLoader.getResource("classpath:jxls/templatestIn/socketInfo.xls")
//				.getInputStream()) {
//        	response.setContentType("application/vnd.ms-excel;charset=utf-8");
//    		response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
//            try (OutputStream os = response.getOutputStream()) {
//                Transformer transformer = TransformerFactory.createTransformer(is, os);
//                
//                //socket接口信息
//                XlsArea socketXlsArea = new XlsArea("Template!A3:V4", transformer);
//                XlsArea socketArea = new XlsArea("Template!A4:V4", transformer);
//                EachCommand socketEachCommand = new EachCommand("socketInfo", "socketList", socketArea);
//                socketXlsArea.addCommand(new AreaRef("Template!A4:V4"), socketEachCommand);
//                Context socketComtext = new Context();
//                socketComtext.putVar("socketList", socketList);
//                socketXlsArea.applyAt(new CellRef("socket!A1"), socketComtext);
//                socketXlsArea.processFormulas();
//                
//                //socket接口服务器信息
//                XlsArea socketServerXlsArea = new XlsArea("Template!A7:U8", transformer);
//                XlsArea socketServerArea = new XlsArea("Template!A8:U8", transformer);
//                EachCommand socketServerEachCommand = new EachCommand("socketServerInfo", "socketServerList", socketServerArea);
//                socketServerXlsArea.addCommand(new AreaRef("Template!A8:U8"), socketServerEachCommand);
//                Context socketServerComtext = new Context();
//                socketServerComtext.putVar("socketServerList", socketServerList);
//                socketServerXlsArea.applyAt(new CellRef("socketServer!A1"), socketServerComtext);
//                socketServerXlsArea.processFormulas();
//                
//                
//                //socket接口调度信息
//                XlsArea ifScheduleXlsArea = new XlsArea("Template!A11:N12", transformer);
//                XlsArea ifScheduleArea = new XlsArea("Template!A12:N12", transformer);
//                EachCommand ifScheduleEachCommand = new EachCommand("socketScheduleInfo", "ifScheduleList", ifScheduleArea);
//                ifScheduleXlsArea.addCommand(new AreaRef("Template!A12:N12"), ifScheduleEachCommand);
//                Context ifScheduleComtext = new Context();
//                ifScheduleComtext.putVar("ifScheduleList", ifScheduleList);
//                ifScheduleXlsArea.applyAt(new CellRef("socketSchedule!A1"), ifScheduleComtext);
//                ifScheduleXlsArea.processFormulas();
//                
//                
//                //接口可见范围信息
//                XlsArea visibleVoXlsArea = new XlsArea("Template!A15:H16", transformer);
//                XlsArea visibleVoArea = new XlsArea("Template!A16:H16", transformer);
//                EachCommand visibleVoEachCommand = new EachCommand("visibleVo", "visibleVoList", visibleVoArea);
//                visibleVoXlsArea.addCommand(new AreaRef("Template!A16:H16"), visibleVoEachCommand);
//                Context visibleVoComtext = new Context();
//                visibleVoComtext.putVar("visibleVoList", visibleVoList);
//                visibleVoXlsArea.applyAt(new CellRef("visibleRelation!A1"), visibleVoComtext);
//                visibleVoXlsArea.processFormulas();
//                
//                transformer.write();
//            }
//        }
//	}
	
}
